import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:maihealth/class/login/page/loginPage.dart';
import 'package:maihealth/class/login/provide/loginProvide.dart';
import 'package:maihealth/class/home/provide/homeProvide.dart';
import 'package:maihealth/class/main/mainPage.dart';
import 'package:maihealth/utils/httpUtils.dart';
import 'package:maihealth/utils/router.dart';
import 'package:maihealth/utils/shareManager.dart';
import 'package:provide/provide.dart';

void main(){
    //配置Provide
    final providers = Providers()
      ..provide(Provider.function((context) => loginProvide()))
      ..provide(Provider.function((context) => homeProvide()));
      HttpUtils.getCookiePath();
    //初始化友盟分享
    shareManager.initUmSdk();
    runApp(ProviderNode(
        providers: providers,
        child: MyApp(),
    ));
}
class MyApp extends StatelessWidget {
 //statusBar设置为透明，去除半透明遮罩 主要是去除安卓
  final SystemUiOverlayStyle _style =SystemUiOverlayStyle(
      statusBarColor: Colors.transparent,
      statusBarBrightness: Brightness.light,
      statusBarIconBrightness:Brightness.dark
  );
  @override
  Widget build(BuildContext context) {
   //将style设置到app
   SystemChrome.setSystemUIOverlayStyle(_style);
    return MaterialApp(
      title: '好脉健康',
      theme: ThemeData(
       primarySwatch: Colors.deepOrange,
      ),
      home: Provide<loginProvide>(builder: (context,child,provide){
        Router.gloabContext = context;
        return   provide.isLogin ?  mainPage() : loginPage();
      })
    );
  }
}
